package example.springmvc.sportscenter.service;

import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;

import example.springmvc.sportscenter.domain.Player;
import example.springmvc.sportscenter.domain.Reservation;
import example.springmvc.sportscenter.domain.SportType;

public class ReservationServiceImpl implements ReservationService {

	private static final SportType TENNIS = new SportType(1,"Tennis");
	private static final SportType SOCCER = new SportType(2,"Soccer");
	
	private List<Reservation> reservations;
	
	public ReservationServiceImpl()
	{
		reservations = new ArrayList<Reservation>();
		reservations.add(new Reservation("COURT1", 
				                         new GregorianCalendar(2012,5,13).getTime(),
				                         10,
				                         new Player("Nadal","N/A"),
				                         TENNIS));
		
		reservations = new ArrayList<Reservation>();
		reservations.add(new Reservation("COURT2", 
				                         new GregorianCalendar(2012,5,13).getTime(),
				                         10,
				                         new Player("Eninho","N/A"),
				                         SOCCER));
		
	}
	@Override
	public List<Reservation> query(String courtName) {
		// TODO Auto-generated method stub
		List<Reservation> results = new ArrayList<Reservation>();
		for(Reservation reservation : this.reservations)
		{
			if(reservation.getCourtName().equals(courtName))
			{
				results.add(reservation);
			}
		}
		return null;
	}

}
